package demo2;


public class Test1 {
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(()->{
            while (true){
                System.out.println("带name的thread");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        },"t1");
        // 设置thread为后台线程
        thread.setDaemon(true);

        thread.start();

    }
}
